package com.gitee.baqkft.code.ui.dlg;

import java.awt.Dimension;
import java.awt.GridBagLayout;
import java.awt.Toolkit;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextPane;

import com.gitee.baqkft.code.ui.layout.GBC;

/**
 * 代码生成结果显示界面
 * 
 * @author chenmingcai
 * @date 2018年6月4日 下午2:15:13
 *
 */

public class GenResultDialog extends JFrame
{
	private static final long serialVersionUID = 1L;
	
	/**
	 * 文本显示区
	 */
	private JTextPane textPane;
	
	private String text;

	public GenResultDialog()
	{
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

		// 设置尺寸
		Toolkit kit = Toolkit.getDefaultToolkit();
		Dimension screenSize = kit.getScreenSize();
		int width = screenSize.width / 2;
		int height = screenSize.height / 2;
		setSize(width, height);
		setLocationByPlatform(true);
		
		initUI();
	}
	
	/**
	 * 界面初始化
	 */
	private void initUI()
	{
		setLayout(new GridBagLayout());
		textPane = new JTextPane();
		JScrollPane pane = new JScrollPane(textPane);
		GBC gbc = new GBC(0, 0).setWeight(1, 1).setFill(GBC.BOTH);
		add(pane, gbc);
	}

	public String getText()
	{
		return text;
	}

	public void setText(String text)
	{
		this.text = text;
		textPane.setText(text);
	}
}
